<template>
  <Modal v-model="showRecord" title="操作记录" width="50%" :footer-hide="true">
    <div class="form_box">
      <dt-grid ref="table" :onFetch='onFetch' :page="page" :height="400" />
      <div class="btn_box">
        <Button style="margin-top: 24px;" @click="cancel">关闭</Button>
      </div>
    </div>
  </Modal>
</template>

<script>
import columnOpt from './opt/columns'
import protectOption from '@/biz/protectOption/protectOption'
export default {
  name: 'DtManagementDataRecord',

  data() {
    return {
      showRecord: false,
      fromType: '',
      page: {
        total: 0
      }
    };
  },

  mounted() {
    
  },

  methods: {
    onFetch(info) {
      console.log(123)
      if(!this.fromType) return
      // 获取案场保护期配置记录
      if(this.fromType === 'buildRob') {
        return protectOption.getBuildProRecord(info).then(res => {
          this.page.total = res.total
          return res.records
        })
      }else if(this.fromType === 'rob') {
        return protectOption.getRobSopRecord(info).then(res => {
          this.page.total = res.total
          return res.records
        })
      }else if(this.fromType === 'protect') {
        return protectOption.getProtectRecord(info).then(res => {
          this.page.total = res.total
          return res.records
        })
      }
    },
    cancel() {
      this.showRecord = false
    },
    show(type) {
      console.log(type)
      this.fromType = type
      this.$refs.table.init(this, new columnOpt(this, type))
      this.$refs.table.fetch()
      this.showRecord = true
    }
  },
};
</script>

<style lang="scss" scoped>
  .btn_box {
    text-align: right;
  }
</style>